package com.ydlclass.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class MethodExecutionTimeAspect {

	@Around("execution(* com.ydlclass.bean.User.*(..))")
	public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
		long startTime = System.currentTimeMillis();
		Object result = joinPoint.proceed(); // 调用目标方法
		long endTime = System.currentTimeMillis();

		System.out.println("方法执行时间：" + (endTime - startTime) + " 毫秒");
		return result;
	}
}
